//
//  PatientDetailVIewController.m
//  Doctors
//
//  Created by 王森 on 16/4/16.
//  Copyright © 2016年 王森. All rights reserved.
//

#import "PatientDetailVIewController.h"
#import "PatientDetaiTableViewCell.h"
#import "UITableView+FDTemplateLayoutCell.h"

@interface PatientDetailVIewController ()

@end

@implementation PatientDetailVIewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTextTitleViewWithFrame:CGRectMake(0, 0, 60, 20) title:@"病患详情" fontSize:18];
    [self addLeftBackBtn:nil];
    
    [self customTableView];
    [self registerNib:@"PatientDetaiTableViewCell"];
    
    __weak typeof(self)weakSelf=self;
    [weakSelf requestData];
    
    
    [self setTableHeaderRefresh:^{
        [weakSelf requestData];
        
        //        [self endReFresh];
        
    }];
    
    
    // Do any additional setup after loading the view.
}


-(void)requestData{
    [self addProgressHUD];
    
    
    [self requestApiWithUrl:@"/order/getMedicalReceiptInfo" dictionary:@{@"receiptId":_ID,} isCache:NO success:^(id responseObject) {
        
        NSDictionary *dic=responseObject[@"receiptInfo"];
        
        NSString *string=[NSString stringWithFormat:@"%@",dic[@"describe"]];
        
        if ([string isEqualToString:@"<null>"]) {
            string=@"无";
        }
        NSArray *arrar=@[@{@"title":@"姓   名：",@"content":dic[@"name"]},
                         @{@"title":@"医保卡号：",@"content":dic[@"medicareCard"]},
                         @{@"title":@"手机号：",@"content":dic[@"mobile"]}
                         ,@{@"title":@"消费金额：",@"content":dic[@"payPrice"]},
                         @{@"title":@"开卡金额：",@"content":dic[@"realPrice"]},
                         @{@"title":@"病情描述：",@"content":string}];
        
        
        self.dataArray=[NSMutableArray arrayWithArray:arrar];
        
        
        NSLog(@"%@",responseObject);
        
        [self endReFresh];
        
        [self removeStatuslable];
        [self.tableview reloadData];
        
    } faild:^(NSError *error) {
        [self endReFresh];
        
    }];
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    
    return [tableView fd_heightForCellWithIdentifier:@"PatientDetaiTableViewCell" cacheByIndexPath:indexPath configuration:^(PatientDetaiTableViewCell *cell) {
        
        [cell fuzhi:self.dataArray index:indexPath];
        
    }];
    //    return 49;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    PatientDetaiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PatientDetaiTableViewCell"];
    cell.accessoryType = UITableViewCellAccessoryNone;
    //    cell.title.text=self.dataArray[indexPath.row][@"title"];
    //    cell.content.text=self.dataArray[indexPath.row][@"content"];
    
    [cell fuzhi:self.dataArray index:indexPath];
    
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
